
//定义枚举类型
enum Color {
    case Red
    case Green
    case Blue
}

enum ComplexColor{
    case Red,Green,Blue,Alpha
}

var c1=Color.Red
var c2:Color
c2 = Color.Green
c1 = .Blue
var c3=c1


func print(color: Color){
    
    switch color {
    case .Red:
        print("Red Color!")
    case .Green:
        print("Green Color!")
    case .Blue:
        print("Blue Color!")
    }
    
}


//指定原始类型
enum WeekDay: Int{
    case Monday=1, Tuesday, Wednesday,Thursday, Friday, Saturday, Sunday
}

var day: WeekDay?
day = WeekDay(rawValue: 7)


var data=WeekDay.Saturday.rawValue


class Point{
    var x=0
    var y=0
    
    init(x:Int, y:Int){
        self.x=x
        self.y=y
    }
}

//枚举关联值
enum Position{
    case Number(Point)
    case Name(String)
}

var p1=Position.Number(Point(x: 123,y: 588))
var p2=Position.Name("Shanghai People's Square")

func print(position: Position){
    
    switch position {
    case .Number(let number):
        print("[\(number.x), \(number.y)]")
    case .Name(let name):
        print(name)
    }
    
}

print(p1)
print(p2)

//定义计算属性、方法、初始化器
enum Sex {
    case Male
    case Female
    
    init?(symbol: Character){
        switch symbol{
        case "M":
            self = .Male
        case "F":
            self = .Female
        default:
            return nil
        }
    }
    
    static var Default: Sex{

            return Sex.Male
    
    }
    func show(){
        switch self{
        case Male:
            print("I am Male!")
        case Female:
            print("I am Female!")
        }
    }
}

var sex=Sex.Female
sex.show()

var defaultSex=Sex.Default

var newSex=Sex(symbol: "F")



